package com.example.demo.thread.join;

/**
 *
 * 两个线程并行运行
 *
 * @author luowj12
 * @since 2021/6/23 10:28
 */
public class ThreadTest {
    //private static final Long count = 10000L;
    public static void main(String[] args){
        long base = System.currentTimeMillis();
        try {
            ThreadJoin t1 = new ThreadJoin("线程1");
            ThreadJoin t2 = new ThreadJoin("线程2");
            t1.start();
            t2.start();

        } catch (Exception e) {
            e.printStackTrace();
        }
        long time = System.currentTimeMillis() - base;
        System.out.println("执行时间："+time);
    }

}
class ThreadJoin extends Thread{
    private static final Long count = 10L;

    public ThreadJoin(String name){
        super(name);
    }

    @Override
    public void run() {
        //super.run();
        for(int i = 1; i <= count; i ++){
            System.out.println(this.getName()+":"+i);
        }
    }
}